
from selenium.webdriver.support.wait import WebDriverWait
# from conn.test import win
import pymysql


class wait_element():



    def look_wait(self,driver,temp,element):
        '''
        显示等待
        :param temp:定位方式
        :param element: 定位元素
        :return: 元素属性对象
        '''
        ele = WebDriverWait(driver, 10).until(lambda x: x.find_element(temp,element))
        return ele

    def send_ele(self,element,text):
        '''
        输入框输入，先清除再输入
        :param element:元素属性对象
        :param text: 输入的值
        :return:
        '''
        element.clear()
        element.send_keys(text)


class  pymysql_get():
    def __init__(self):
        self.sql_lj = pymysql.connect(host='124.221.52.199', port=3306, user='root', password='newzer.cn',
                                 charset='utf8',database='xbt_test')
        self.cousor = self.sql_lj.cursor()
    def sql_get(self,sql):
        '''
        sql执行方法
        :param sql:sql语句
        :return:
        '''
        try:
            self.cousor.execute(sql)
            print("sql执行成功")
            data = self.cousor.fetchall()
            print(f"执行的结果为{data}")
        except Exception as e:
            print(f"错误类型为：{e}")
        finally:
            self.cousor.close()
            self.sql_lj.close()
if __name__ == '__main__':
    sql = "SELECT * FROM user_info  WHERE  mobile_num='16200000001';"
    ww=pymysql_get().sql_get(sql)





# """
# 图鉴官网：http://www.ttshitu.com/
# 每次消耗 0.002积分
# """
# import base64
# import json
# import requests
#
# def base64_api(uname, pwd, img, typeid):
#     with open(img, 'rb') as f:
#         base64_data = base64.b64encode(f.read())
#         b64 = base64_data.decode()
#     data = {"username": uname, "password": pwd, "typeid": typeid, "image": b64}
#     result = json.loads(requests.post("http://api.ttshitu.com/predict", json=data).text)
#     if result['success']:
#         return result["data"]["result"]
#     else:
#         return result["message"]
#
#
#
# if __name__ == "__main__":
#     img_path = "C:/Users/Administrator/Desktop/file.jpg"
#     result = base64_api(uname='[用户名]', pwd='[密码]', img='test1.jpg', typeid=3)
#     print(result)
